package viroyal.com.base.activity.engineering;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.suntiago.network.network.ErrorCode;

import rx.functions.Action1;
import viroyal.com.base.AppConfig;
import viroyal.com.base.R;
import viroyal.com.base.face.bean.DeviceInfo;
import viroyal.com.base.net.rsp.GetDeviceInfoResponseS;
import viroyal.com.dev.NFCMonitorBaseActivity;
import viroyal.com.dev.splash.ConfigDevice;

public class DeviceInfoActivity extends NFCMonitorBaseActivity<DeviceInfoDelegate, DeviceInfoModel> {

  @Override
  protected Class<DeviceInfoDelegate> getDelegateClass() {
    return DeviceInfoDelegate.class;
  }

  @Override
  protected Class<DeviceInfoModel> getModelClass() {
    return DeviceInfoModel.class;
  }

  @Override
  protected void initView(Bundle savedInstanceState) {
    super.initView(savedInstanceState);
    viewDelegate.initView();
    Log.i(TAG, "initView: [ConfigDevice.getDeviceId()]"+ ConfigDevice.getDeviceId());
    addRxSubscription(iModel.getDeviceInfo(ConfigDevice.getDeviceId(), getDeviceInfoResponseS -> {
      if (getDeviceInfoResponseS.error_code == ErrorCode.SUCCESS) {
        viewDelegate.deviceInfo(getDeviceInfoResponseS.extra);
      } else {
        Toast.makeText(this, getDeviceInfoResponseS.extra.message, Toast.LENGTH_SHORT).show();
      }

    }));
  }
}
